<?php
/**
* Class and Function List:
* Function list:
* - get()
* - getNumber()
* - getIntNumber()
*/
class Request
{
    function get($varname, $clean = true)
    {
	
    	
		$request = array_merge($_GET, $_POST);
    	if (isset($request[$varname])){
        	$pattern = '/<[^>]+>/i';
        	$replacement = '';

        	if(is_string($request[$varname]) ){
				$request[$varname] = trim($request[$varname]);
				if( $clean )
					$request[$varname] = preg_replace($pattern, $replacement, $request[$varname]);
        	}

            return $request[$varname];
        }
        return '';
    }

    function getNumber($varname, $clean = true)
    {
        $str_value = Request::get($varname, $clean);
        return is_numeric($str_value) ? $str_value : 0;

    }

    function getIntNumber($varname, $clean = true)
    {
        return intval(Request::getNumber($varname, $clean));

    }
    
    /**
     * Check if the $_POST or $_GET variable is set and not empty
     *
     * @param unknown $varname
     * @return true if $varname isset and $varname is not empty; false otherwise
     */    
    function isSetParameter($varname)
    {
    	$request = array_merge($_GET, $_POST);
    	return (isset($request[$varname]) && $request[$varname]!="");
    }
}